package edu.ynu.se.xiecheng.achitectureclass.entity;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import edu.ynu.se.xiecheng.achitectureclass.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;

@Entity
@Getter
@Setter
@Where(clause = "is_deleted = 0")
public class Oorder extends LogicEntity {
    //1.不能取名为order,因为order是mySQL关键字.(42000错误
    //2.外键的对象不能通过直接传相应的id就给对应的表对应列赋值
    // (这样做了只会显示null).
    //必须是通过set对象,才能够在表对应列赋值
    @Column(nullable = false,
            columnDefinition="INT default 0")
    private Integer payStatus;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customer_id")
    @JsonIgnoreProperties("oorders")
    private Customer customer;

    @OneToMany(mappedBy = "oorder",
            fetch = FetchType.LAZY,
            cascade = CascadeType.ALL)
    @JsonIgnoreProperties("oorder")
    private Set<LineItem> lineItems;

}
